package com.llynic.designdemo.strategymode;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Component
public class PromotionCaculationFactory {
    public static void main(String[] args) {
        getPromotionCaculation("1");
    }
    public static void getPromotionCaculation(String promotion) {
        try {
            ApplicationContext ctx = new ClassPathXmlApplicationContext(
                    new String[]{"beanconfig.xml"});
            Class cls = Class.forName("com.llynic.designdemo.strategymode.Promotion1");
            System.out.println(cls);
            Method[] methods = cls.getMethods();
            for (Method m: methods) {
                System.out.println(m.getName());
            }
        } catch (ClassNotFoundException e) {

            e.printStackTrace();
        }

        switch (promotion) {
            case "1":
                System.out.println("first");
            case "2":
                System.out.println("second");
            case "3":
                System.out.println("third");
        }
    }

    ;
}
